<!DOCTYPE html>
<html>
<head>
    {include file="layout:_meta" /}
</head>
<body>
<div class="layui-fluid" style="padding-top: 20px">
    <div class="layui-card">
        <div class="layui-card-header">App管理</div>
        <div class="layui-card-body">
            <form class="layui-form" lay-filter="layuiadmin-form-admin" action="{:url('config/version')}">
                <div class="layui-tab layui-tab-brief" >
                    <ul class="layui-tab-title">
                        <li>Android管理</li>
                    </ul>
                    <div class="layui-tab-content" >
                        <div class="layui-tab-item layui-show">
                            <div class="layui-tab-item layui-show">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">versionCode：</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="android[versionCode]" placeholder="请输入versionCode版本号如：1 (必须是整数)" autocomplete="off" class="layui-input" value="{:isset($list.android.versionCode)?$list.android.versionCode:''}">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">versionName：</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="android[versionName]" placeholder="请输入versionName版本号如：1.2.1" autocomplete="off" class="layui-input" value="{:isset($list.android.versionName)?$list.android.versionName:''}">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">发布内容：</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="android[versionInfo]" placeholder="请输入更新发布内容" autocomplete="off" class="layui-input" value="{:isset($list.android.versionInfo)?$list.android.versionInfo:''}">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <div class="layui-inline" style="width: 500px">
                                        <label class="layui-form-label">下载地址：</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="android[downloadUrl]" id="up_app_up"  placeholder="请输入下载地址:http://www.xxx.com/xxx.apk" autocomplete="off" class="layui-input" value="{:isset($list.android.downloadUrl)?$list.android.downloadUrl:''}">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <button type="button" class="layui-btn layui-btn-checked" id="upApp" style="float: left;">上传APP</button>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">强制更新：</label>
                                    <div class="layui-input-block">
                                        <input type="radio" name="android[forceUpdate]" value="true" title="强制更新"  {eq name="list.android.forceUpdate" value="true"}checked{/eq} >
                                        <input type="radio" name="android[forceUpdate]" value="false" title="选择更新" {eq name="list.android.forceUpdate" value="false"}checked{/eq} >
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <div class="layui-input-block">
                                        <button class="layui-btn" lay-submit  lay-filter="submit">确认</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

{include file="layout:_footer" /}
<script>
    var images = [];
    layui.config({
        base: '__static__/admin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form', 'upload'], function(){
        var form = layui.form,$ = layui.$, upload = layui.upload, layedit  = layui.layedit;

        //监听表单提交
        form.on('submit(submit)', function(data){
            layer.confirm('您确认要提交吗？', {
                btn: ['确认','取消'] //按钮
            }, function(index){
                $.post(data.form.action, data.field, function (res) {
                    var icon = 5;
                    if (res.code) {
                        icon = 6;
                    }
                    layer.msg(res.msg, {icon: icon, time: 1500});
                }, 'json');
            }, function(){
                layer.msg('已取消..');
                return false;
            });
            return false;
        });

        //app上传
        upload.render({ //允许上传的文件后缀
            elem: '#upApp'
            ,url: "{:url('upload/image')}?type=app" //改成您自己的上传接口
            ,accept: 'file' //普通文件
            ,exts: 'apk|wgt' //只允许上传压缩文件
            ,done: function(res){
                //如果上传失败
                if(res.code == 0){
                    return layer.msg('上传失败');
                }
                //上传成功
                $('#up_app_up').val("{:config('qiniu.uploadUrl')}"+res.data);
                layer.msg('上传成功');
            }
        });

    })
</script>
</body>
</html>